var utilMd5 = require('utils/md5'); 
var url = "https://master.shoppingwar.cn/api/";
var APP_ID = "oo0Ds5YkHMFrD5Ck";
var encstr = "shoppingwarjurentech123";

function singleprice(numbers){
    return (numbers / 100).toFixed(2);
}
function md5Start(arr) {
    var arrays = arr.sort();
    var data1 = "";
    for (var i = 0; i < arrays.length; i++) {
        data1 += arrays[i];
    }
    // console.log(encstr + APP_ID + data1);
    var md5z = utilMd5.md5(encstr + APP_ID + data1).toUpperCase();
    return md5z;
}
// function md5(v){
//     return utilMd5.md5(v);
// }
function judgeuser(){ 
	return new Promise(function (resolve, reject) {
		var user_id = wx.getStorageSync("user_id");//获取用户id
		if (!user_id) {
			wx.navigateTo({
				url: '../wxJurisdiction/wxJurisdiction',
			})
		}
		resolve(true)
	})
	
}
//限制输入的函数
function regStrFn(str) {
	let reg = /([^\u0020-\u007E\u00A0-\u00BE\u2E80-\uA4CF\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFFEF\u0080-\u009F\u2000-\u201f\u2026\u2022\u20ac\r\n])|(\s)/g,
		indexArr = reg.exec(str);
	if (str.match(reg)) {
		str = str.replace(reg, '');
	}
	let obj = {
		val: str,
		index: indexArr
	}
	return obj
}
module.exports = {
    md5Start: md5Start,
    APP_ID: APP_ID,
    url: url,
    singleprice: singleprice,
	judgeuser: judgeuser,
	regStrFn: regStrFn,
}
